unit uDB;

interface

uses
  SysUtils, Classes, DB, ADODB;

type
  TDataModule1 = class(TDataModule)
    conA: TADOConnection;
    qry1: TADOQuery;
    procedure DataModuleCreate(Sender: TObject);
  private
    { Private declarations }
  public

   procedure getUserInfo(ALoginName:string);
   procedure getOrgInfo();
    { Public declarations }
  end;

var
  DataModule1: TDataModule1;

implementation
 uses uVar;
{$R *.dfm}

procedure TDataModule1.DataModuleCreate(Sender: TObject);
begin
  //.\data\dbdb.mdb
  conA.ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=.\data\dbdb.mdb;Persist Security Info=False';
end;

procedure TDataModule1.getOrgInfo;
begin
  qry1.Close;
  qry1.SQL.Text := 'select * from T_ORGANIZATION where ID = ' + Inttostr(CurUser.OrgID);
  qry1.Open;
  qry1.First;
  CurOrg.ID := qry1.FieldByName('id').AsInteger;
  CurOrg.ParentID := qry1.FieldByName('I_PARENT_ID').AsInteger;
  CurOrg.Code := qry1.FieldByName('C_CODE').AsString;
  CurOrg.Name_ZH := qry1.FieldByName('C_NAME_ZH').AsString;
  CurOrg.Name_EN :=  qry1.FieldByName('C_NAME_EN').AsString;
  CurOrg.ZIP := qry1.FieldByName('C_ZIP').AsString;
end;

procedure TDataModule1.getUserInfo(ALoginName: string);
begin
  qry1.Close;
  qry1.SQL.Text := 'select * from t_user where C_LOGIN_NAME = ''' + ALoginName+'''';
  qry1.Open;
  qry1.First;
  CurUser.ID := qry1.FieldByName('id').AsInteger;
  CurUser.OrgID := qry1.FieldByName('I_ORGANIZATION_ID').AsInteger;
  CurUser.LoginName := qry1.FieldByName('C_LOGIN_NAME').AsString;
  CurUser.Password := qry1.FieldByName('C_LOGIN_PASSWORD').AsString;
  CurUser.Name_ZH :=  qry1.FieldByName('C_NAME_ZH').AsString;
  CurUser.Name_EN  :=  qry1.FieldByName('C_NAME_EN').AsString;
  CurUser.EMail :=  qry1.FieldByName('C_EMAIL').AsString;
  CurUser.MobilePhone := qry1.FieldByName('C_MOBILE_PHONE').AsString;
  CurUser.LinePhone := qry1.FieldByName('C_LINE_PHONE').AsString;
end;

end.
